package ooad.gof.composite;
import java.util.ArrayList;
import java.util.List;
public class Composite extends Component{
	private List<Component> clist;
	public Composite(String name){
		super(name);
		clist = new ArrayList<Component>();
	}
	public Composite(){
		clist = new ArrayList<Component>();
	}
	
	@Override
	public void operation() {
		System.out.println("这是组合的操作.....");
	}

	@Override
	public void add(Component component) {
		clist.add(component);		
	}

	@Override
	public void remove(Component component) {
		clist.remove(component);		
	}

	@Override
	public void getAll() {
		for (Component c : clist){
			System.out.println(c.getName());
		}		
	}
}
